
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">
<h:body>
	<ui:composition template="/template.xhtml">
		<ui:define name="center">
			<p:panel header="Categorias">
				<h:form id="msg">
					
				</h:form>
				<h:form id="formEntrada">
					<p:dialog height="150" widgetVar="dlg" resizable="false"
						 draggable="false" header="Excluir" closable="false">
						<h:panelGrid columns="1">
							<h:outputLabel value="Excluir categoria?" />
							<h:panelGroup style="margin-top:30px">
								<p:commandButton id="a" value="Sim"
									action="#{beanCategoria.remover}"
									update="formEntrada formTabela" onsuccess="dlg.hide()"
									onerror="dlg.hide()"/>
								<p:commandButton value="Não" onclick="dlg.hide()"
									style="margin-left:30px" />
							</h:panelGroup>
						</h:panelGrid>
					</p:dialog>

					<h:inputHidden value="#{beanCategoria.categoria.codigo}" />
					<h:panelGrid columns="3">
						<h:outputLabel value="Nome:" />
						<p:inputText id="inputNome"
							value="#{beanCategoria.categoria.nome}" required="true"
							requiredMessage="Insira um nome" style="font-size:10pt" />
						<p:message for="inputNome"/>
						<h:outputLabel value="Cor:" />
						<p:colorPicker id="cp" showControls="false" required="true" requiredMessage="Insira uma cor"
							value="#{beanCategoria.categoria.cor}" converter="cpConverter">
						</p:colorPicker>
					<p:message for="cp"/>
					</h:panelGrid>

					<p:commandButton value="Salvar" action="#{beanCategoria.salvar}"
						update="formEntrada formTabela" />

				</h:form>



				<h:form id="formTabela">

					<p:dataTable id="tabelaCategoria" var="categoria"
						emptyMessage="Não há registros." value="#{beanCategoria.lista}"
						selection="#{beanCategoria.categoria}" selectionMode="single"
						style="margin-top:15px;font-size:12pt" paginator="true" rows="10"
						onRowSelectUpdate="formEntrada">

						<p:column style="background-color: rgb(#{categoria.cor})"
							headerText="Nome">
							<h:outputText value="#{categoria.nome}" />
						</p:column>

						<p:column style="width:30px">
							<p:commandLink action="#{beanCategoria.editar(categoria)}"
								update="formEntrada" onclick="dlg.show()"
								style="margin-left:4px">
								<p:graphicImage value="icone/delete.png" />
							</p:commandLink>
						</p:column>

					</p:dataTable>

				</h:form>
			</p:panel>
		</ui:define>
	</ui:composition>
</h:body>
</html>